package com.pig4cloud.pig.demo.controller;

import com.pig4cloud.pig.common.security.annotation.Inner;
import com.pig4cloud.pig.demo.dto.Result;
import com.pig4cloud.pig.demo.dto.SmartAppGoodsDto;
import com.pig4cloud.pig.demo.feign.SmartAppGoodsFeign;
import com.pig4cloud.pig.demo.service.SmartAppGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("SmartAppGoods 商品接口")
@RestController
@RequestMapping("demo-biz")
public class SmartAppGoodsController implements SmartAppGoodsFeign {

	@Autowired
	SmartAppGoodsService smartAppGoodsService;

	@ApiOperation("获取商品列表")
	@GetMapping("/goods/getList")
	@Override
	public Result<List<SmartAppGoodsDto>> getList() {
		return smartAppGoodsService.getList();
	}

	@ApiOperation("通过id获取商品")
	@GetMapping("/goods/getById/{id}")
	@Override
	public Result<SmartAppGoodsDto> getById(@PathVariable("id") Long id) {
		return smartAppGoodsService.getById(id);
	}

	@ApiOperation("通过id删除商品")
	@DeleteMapping("/goods/delete/{id}")
	@Override
	public Result delete(@PathVariable("id") Long id) {
		return smartAppGoodsService.delete(id);
	}

	@ApiOperation("新增商品")
	@PostMapping("/goods/add")
	@Override
	public Result add(@RequestBody SmartAppGoodsDto goodsDto) {
		return smartAppGoodsService.add(goodsDto);
	}

	@ApiOperation("更新商品")
	@PutMapping("/goods/update")
	@Override
	public Result update(@RequestBody SmartAppGoodsDto goodsDto) {
		return smartAppGoodsService.update(goodsDto);
	}

	@GetMapping("/testhhhhhhh")
	public SmartAppGoodsDto testhhhhhhh() {
		return new SmartAppGoodsDto();
	}
}
